package com.devops.admin.graphql;

import com.devops.admin.po.DOSResourceSubTypePo;
import com.devops.admin.service.DOSResourceTypeService;
import com.devops.common.annotation.DOSLog;
import com.devops.constant.DevOpsConstant;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsQuery;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @ClassName DOSResourceTypeDataFetcher
 * @Description TODO
 * @Author heyabo
 * @Date 2022/8/4 11:39
 * @Version 1.0
 **/
@DgsComponent
public class DOSResourceTypeDataFetcher {

    @Autowired
    private DOSResourceTypeService dosResourceTypeService;

    /**
     * @Author heyabo
     * @Description 获取全部的资源类型
     * @Date 11:50 2022/6/8
     * @Param []
     * @return java.util.List<com.devops.admin.model.DOSResourceType>
     **/
    @DgsQuery
    @RequiresPermissions(value = {DevOpsConstant.RoleCode.LOGIN_USER},logical = Logical.OR)
    @DOSLog(description = "获取全部的资源类型")
    public List<DOSResourceSubTypePo> getAllResourceType(){

        return dosResourceTypeService.getResourceTypes();
    }
}
